<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <!-- 对不识别viewport设备优化 -->
    <meta name="HandheldFriendly" content="true">
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    <title>微信分享示例</title>
    <link rel="icon" type="image/x-icon" href="./favicon.ico" />
</head>

<body>
    <h3>这是微信分享示例</h3>
</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="./js/jquery1.7.2.js"></script>
<script src="./js/jquery.cookie.js"></script>\
<script>
    $(function () {
        var url = window.location.href;
        // 配置微信公众号验证权限
        $.ajax({
            type: 'post',
            url: 'http://t.scsj.net.cn/admin/API/wxShare.php',
            data: {
                url: url
            },
            success: function (data) {
                data = JSON.parse(data);
                console.log(data)
                wx.config({
                    debug: true,
                    appId: data.appId, // 企业号的唯一标识
                    timestamp: data.timestamp, // 签名的时间戳
                    nonceStr: data.nonceStr, // 生成签名的随机串
                    signature: data.signature, // 签名
                    jsApiList: [
                        'onMenuShareTimeline',
                        'onMenuShareAppMessage',
                        'onMenuShareQQ',
                        'onMenuShareWeibo',
                        'onMenuShareQZone'
                    ]
                })
            },
            error: function () {
                alert("配置失败")
            }
        })
        window.share_config = {
            'share': {
                'imgUrl': './favicon.ico',
                'desc': '商超世界爆品来袭',
                'title': '爆品来袭',
                'link': "http://www.yongbo.xin",
                'success': function () {
                    alert("已分享")
                },
                'cancel': function () {
                    alert("已取消")
                }
            }
        }
        wx.ready(function () {
            wx.onMenuShareAppMessage(share_config.share); // 分享给好友
            wx.onMenuShareTimeline(share_config.share); // 分享到朋友圈
            wx.onMenuShareQQ(share_config.share); // 分享给手机QQ
        })
    })
</script>

</html>